
#include <string.h>
#include "hardware.h"
#include "sys.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "debug.h"
#include "fout.h"
#include "USART.h"
#include "cmd.h"
#include "modem.h"
#include "status.h"
#include "modem.h"
#include "macros.h"


dev_status_t dev_status;

char srv_port[8]="";
char srv_ip_addr[16]="";
unsigned long send_to_srv_period = 0;

static modem_net_msg_t net_msg;

void status_init ( void )
{
	memset(&dev_status, 0, sizeof(dev_status));
}

void status_set_param ( char *ip_addr, char *port, unsigned long send_period )
{	
	strcpy(net_msg.ip_addr,ip_addr); 
	strcpy(net_msg.port,port); 
	send_to_srv_period = send_period * 1000; /* in msec */
	dbg("send_to_srv_period: %d", send_to_srv_period); //Dima
}

void status_task ( void *pvParameters )
{
	for(;;)
	{
		if ( send_to_srv_period )
		{
			xQueueSend(modem_cmd_queue, &net_msg, portMAX_DELAY); //portMAX_DELAY
			
			vTaskDelay(send_to_srv_period MSEC);
		}

		taskYIELD();
	}
}
